﻿using Ducu.GLB.Global;
using Ducu.GLB.Global.Story;
using Ducu.SRV.ServiceInteface;
using Ducu.SRV.ViewModel.Plan;
using Ducu.SRV.ViewModel.Plan.EditorTemplates;
using Ducu.SRV.ViewModel.Plan.Shared;
using Ducu.SRV.ViewModel.Shared;
using Ducu.SRV.ViewModel.Task.Shared;
using System;
using System.Collections.Generic;

namespace Ducu.SRV.UIDevService
{
    public class PlanService : IPlanService
    {
        public int New(NewModel model, IEnumerable<int> DaysInWeek)
        {
            return 216;
        }

        public void Edit(_NewOrEditModel model, int planId)
        {
            //do nothing  
        }

        public JoinResult Join(int planId)
        {
            if (planId == Plan.ID_VOA)
            {
                return JoinResult.FailForFull;
            }
            return JoinResult.Succeed;
        }

        public _NeedFulfilModel GetNeedFulfil()
        {
            return new _NeedFulfilModel
            {
                Items = new List<NameIdModel>
                {
                    //new NameIdModel
                    //{ 
                    //    Id = Plan.ID_READING, 
                    //    Name = Plan.TITLE_READING
                    //},
                    new NameIdModel
                    {
                        Id = Plan.ID_VOA,
                        Name = Plan.TITLE_VOA                       
                    }
                }
            };
        }

        public _NeedAcceptModel GetNeedAccept()
        {
            return new _NeedAcceptModel();
        }

        public EditModel GetEdit(int planId)
        {
            EditModel VOA = new EditModel
            {
                Origin = new _NewOrEditModel
                {
                    Title = Plan.TITLE_VOA,
                    Description = Plan.DESCRIPTION_VOA,
                    KeyWords = "英语 VOA",
                    Expire = 3,
                    From = new DateTime(2016, 2, 13),
                    To = new DateTime(2016, 12, 31),
                    FulfilWeekdays = new List<int> { 1, 2, 3, 4, 5 },
                    OptionalNumbersOfSupervisors = new[] { 3, 4, 5 }
                }
            };
            return VOA;
        }

        public ShowModel GetShow(int planId)
        {
            _ShowItemModel VOA = new _ShowItemModel
            {
                Title = new NameIdModel
                {
                    Id = Plan.ID_VOA,
                    Name = Plan.TITLE_VOA
                }
            };
            return new ShowModel { PublishContent = VOA };
        }

        public _ShowItemBodyModel GetShowItemBody(int planId)
        {
            return new _ShowItemBodyModel
            {
                Description = Plan.DESCRIPTION_VOA,
                Vower = new NameIdModel
                {
                    Id = User.ID_YEZI,
                    Name = User.NAME_YEZI
                },
                FulfilWeekdays = new List<int> { 1, 2, 3, 4, 5 },
                Keywords = new List<NameIdModel> 
                        { 
                            new NameIdModel
                            {
                                Id=Keyword.ID_ENGLISH,
                                Name = Keyword.NAME_ENGLISH
                            },
                            new NameIdModel
                            {
                                Id=Keyword.ID_ENGLISH_VOA,
                                Name = Keyword.NAME_ENGLISH_VOA
                            }
                        },
                CreateTime = new DateTime(2016, 2, 18, 13, 24, 18),
            };
        }

        public bool IsCurrentUserVower(int id)
        {
            if (id > 10000)
            {
                return false;
            }
            return true;
        }



        public int GetCount(bool due, bool expire, bool full, string my, string keyword, int? userId)
        {
            throw new NotImplementedException();
        }

        public IndexModel Get(bool due, bool expire, bool full, string my, string keyword, int? userId, Pager pager)
        {
            throw new NotImplementedException();
        }

        public IndexModel Get(string keyword, Pager pager)
        {
            _ShowItemModel VOA = new _ShowItemModel
            {
                Title = new NameIdModel
                {
                    Id = Plan.ID_VOA,
                    Name = Plan.TITLE_VOA
                },
                //Body = new _ShowItemBodyModel
                //{
                //    Description = Plan.DESCRIPTION_VOA,
                //    Vower = new NameIdModel
                //    {
                //        Id = User.ID_YEZI,
                //        Name = User.NAME_YEZI
                //    },
                //    FulfilWeekdays = new List<int> { 1, 3, 5 },
                //    Keywords = new List<NameIdModel> 
                //{ 
                //    new NameIdModel
                //    {
                //        Id=Keyword.ID_ENGLISH,
                //        Name = Keyword.NAME_ENGLISH
                //    },
                //    new NameIdModel
                //    {
                //        Id=Keyword.ID_ENGLISH_VOA,
                //        Name = Keyword.NAME_ENGLISH_VOA
                //    }
                //},
                //    Created = new DateTime(2016, 2, 18, 13, 24, 18),
                //    HasSupervisor = 1
                //}
            };

            _ShowItemModel BBC = new _ShowItemModel
            {
                Title = new NameIdModel
                {
                    Id = Plan.ID_BBC,
                    Name = Plan.TITLE_BBC
                },
                //Body = new _ShowItemBodyModel
                //{
                //    Description = Plan.DESCRIPTION_BBC,
                //    Vower = new NameIdModel
                //    {
                //        Id = User.ID_ABU,
                //        Name = User.NAME_ABU
                //    },
                //    FulfilWeekdays = new List<int> { 2, 4, 6 },
                //    Keywords = new List<NameIdModel> 
                //{ 
                //    new NameIdModel
                //    {
                //        Id=Keyword.ID_ENGLISH,
                //        Name = Keyword.NAME_ENGLISH
                //    }
                //},
                //    Created = new DateTime(2016, 2, 19, 13, 01, 17),
                //    From = new DateTime(2016, 2, 22),
                //    HasSupervisor = 0
                //}
            };


            _ShowItemModel SWIM = new _ShowItemModel
            {
                Title = new NameIdModel
                {
                    Id = Plan.ID_EXERCISE_SWIM,
                    Name = Plan.TITLE_EXERCISE_SWIM
                },
                //Body = new _ShowItemBodyModel
                //{
                //    Description = Plan.DESCRIPTION_SWIM,
                //    Vower = new NameIdModel
                //    {
                //        Id = User.ID_ABU,
                //        Name = User.NAME_ABU
                //    },
                //    FulfilWeekdays = new List<int> { 1, 2, 3, 4, 5 },
                //    Keywords = new List<NameIdModel> 
                //{ 
                //    new NameIdModel
                //    {
                //        Id=Keyword.ID_EXERCISE,
                //        Name = Keyword.NAME_EXERCISE
                //    }
                //},
                //    CanEdit = true,
                //    Created = new DateTime(2016, 2, 19, 13, 01, 17),
                //    From = new DateTime(2016, 2, 19),
                //    To = new DateTime(2016, 12, 31),
                //    HasSupervisor = 1
                //}
            };

            return new IndexModel
            {
                Items = new List<_ShowItemModel> 
                { 
                    VOA,
                    BBC,
                    SWIM
                }
            };
        }

        public int GetSumCount(string keyword)
        {
            return 7;
        }


        public bool CanLeave(int planId, DateTime date)
        {
            throw new NotImplementedException();
        }


        public void Stop(int id)
        {
            throw new NotImplementedException();
        }
    }
}
